package com.dy.drp.controller;

import com.dy.drp.entity.User;
import com.dy.drp.service.IUserService;
import com.dy.drp.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: dy
 * @Date: 2022/4/1 - 04 - 01 - 17:17
 * @Description: com.dy.drp.controller
 * @version: 1.0
 */
@RestController
@RequestMapping("/login")
@Api(tags = "用户登录注册接口")
public class LoginController {
    @Autowired
    private IUserService userService;

    @GetMapping("/userLogin/{userName}/{password}")
    @ApiOperation("用户登录方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userName", value = "用户名"),
            @ApiImplicitParam(name = "password", value = "用户密码")
    })
    public UserVo userLogin(@PathVariable("userName")String userName
                            , @PathVariable("password")String password ){
        User user = new User();
        user.setUserName(userName);
        user.setUserPwd(password);
        UserVo userVo = userService.getOneUserAndPowerByUser(user);
        return userVo;
    }
}
